package com.kukudexin.safety;

/**
 * @author: 酷酷的鑫
 * @description:
 */
public class Test01 {

    private Object objectLock = new Object();
    public static void main(String[] args) {
        new Test01().print();
    }
    private void print(){
        new Thread(()->{
            System.out.println(Thread.currentThread().getName() + ">1<");
            synchronized (objectLock){
                try {
                    objectLock.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println(Thread.currentThread().getName() + ">2<");

        }).start();

        try {
            Thread.sleep(3000);
            // 主线程3s 之后唤醒该子线程
            synchronized (objectLock) {
                objectLock.notify();
            }
        } catch (Exception e) {
            e.printStackTrace();

        }
    }

}
